package com.ruoyi.web.controller.production.regulator;

import java.util.List;

import com.ruoyi.common.annotation.PropertyInject;
import com.ruoyi.common.enums.InjectType;
import com.ruoyi.production.domain.regulator.RegulatorPurchaseApply;
import com.ruoyi.production.service.regulator.IRegulatorPurchaseApplyService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 调节剂购买申请Controller
 *
 * @author testlove
 * @date 2021-07-11
 */
@RestController
@RequestMapping("/system/regulatorApply")
public class RegulatorPurchaseApplyController extends BaseController
{
    @Autowired
    private IRegulatorPurchaseApplyService regulatorPurchaseApplyService;

    /**
     * 查询调节剂购买申请列表
     */
    @PreAuthorize("@ss.hasPermi('system:regulatorApply:list')")
    @GetMapping("/list")
    public TableDataInfo list(RegulatorPurchaseApply regulatorPurchaseApply)
    {
        startPage();
        List<RegulatorPurchaseApply> list = regulatorPurchaseApplyService.selectRegulatorPurchaseApplyList(regulatorPurchaseApply);
        return getDataTable(list);
    }

    /**
     * 导出调节剂购买申请列表
     */
    @PreAuthorize("@ss.hasPermi('system:regulatorApply:export')")
    @Log(title = "调节剂购买申请", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(RegulatorPurchaseApply regulatorPurchaseApply)
    {
        List<RegulatorPurchaseApply> list = regulatorPurchaseApplyService.selectRegulatorPurchaseApplyList(regulatorPurchaseApply);
        ExcelUtil<RegulatorPurchaseApply> util = new ExcelUtil<RegulatorPurchaseApply>(RegulatorPurchaseApply.class);
        return util.exportExcel(list, "调节剂购买申请数据");
    }

    /**
     * 获取调节剂购买申请详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:regulatorApply:query')")
    @GetMapping(value = "/{regulatorPurchaseApplyId}")
    public AjaxResult getInfo(@PathVariable("regulatorPurchaseApplyId") Long regulatorPurchaseApplyId)
    {
        return AjaxResult.success(regulatorPurchaseApplyService.selectRegulatorPurchaseApplyById(regulatorPurchaseApplyId));
    }

    /**
     * 新增调节剂购买申请
     */
    @PreAuthorize("@ss.hasPermi('system:regulatorApply:add')")
    @Log(title = "调节剂购买申请", businessType = BusinessType.INSERT)
    @PostMapping
    @PropertyInject(type = InjectType.Insert)
    public AjaxResult add(@RequestBody RegulatorPurchaseApply regulatorPurchaseApply)
    {
        return toAjax(regulatorPurchaseApplyService.insertRegulatorPurchaseApply(regulatorPurchaseApply));
    }

    /**
     * 修改调节剂购买申请
     */
    @PreAuthorize("@ss.hasAnyPermi('system:regulatorApply:edit,system:regulatorApply:permit')")
    @Log(title = "调节剂购买申请", businessType = BusinessType.UPDATE)
    @PutMapping
    @PropertyInject(type = InjectType.Update)
    public AjaxResult edit(@RequestBody RegulatorPurchaseApply regulatorPurchaseApply)
    {
        return toAjax(regulatorPurchaseApplyService.updateRegulatorPurchaseApply(regulatorPurchaseApply));
    }

    /**
     * 删除调节剂购买申请
     */
    @PreAuthorize("@ss.hasPermi('system:regulatorApply:remove')")
    @Log(title = "调节剂购买申请", businessType = BusinessType.DELETE)
	@DeleteMapping("/{regulatorPurchaseApplyIds}")
    public AjaxResult remove(@PathVariable Long[] regulatorPurchaseApplyIds)
    {
        return toAjax(regulatorPurchaseApplyService.deleteRegulatorPurchaseApplyByIds(regulatorPurchaseApplyIds));
    }
}
